package com.lnu.information.biz.impl;

import com.lnu.information.biz.CompanyBiz;
import com.lnu.information.common.Constant;
import com.lnu.information.dto.*;
import com.lnu.information.entity.CompanyCompanyBackgroundCommerceImformationEntity;
import com.lnu.information.entity.CompanyfzjgEntity;
import com.lnu.information.service.CompanyService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author : jian.zhang-2
 * @description:
 * @date : Create in 1:26 PM 2022/2/18
 * @modified By :
 */
@Component
public class CompanyBizImpl implements CompanyBiz{

    @Resource
    private CompanyService companyService;

    @Override
    public QueryCompanyResponseDTO queryTableData(String tableName, QueryCompanyRequestDTO queryCompanyRequestDTO) {
        Map resultMap = companyService.queryTableData(tableName, queryCompanyRequestDTO);
        QueryCompanyResponseDTO queryCompanyResponseDTO = new QueryCompanyResponseDTO();
        queryCompanyResponseDTO.setResults(resultMap);
        queryCompanyResponseDTO.setCode(Constant.DEFAULT_SUCCESS_CODE);
        queryCompanyResponseDTO.setMsg(Constant.DEFAULT_SUCCESS_MSG);
        queryCompanyResponseDTO.setTotal(Constant.DEFAULT_TOTAL);
        return queryCompanyResponseDTO;
    }

    @Override
    public QueryCompanyResponseDTO queryJoinTableData(QueryCompanyTopTenCurrentShareHoldersRequestDto queryCompanyRequestDTO) {
        Map resultMap = companyService.queryJoinTableData(queryCompanyRequestDTO.getCompanyId());
        QueryCompanyResponseDTO queryCompanyResponseDTO = new QueryCompanyResponseDTO();
        queryCompanyResponseDTO.setResults(resultMap);
        queryCompanyResponseDTO.setCode(Constant.DEFAULT_SUCCESS_CODE);
        queryCompanyResponseDTO.setMsg(Constant.DEFAULT_SUCCESS_MSG);
        queryCompanyResponseDTO.setTotal(Constant.DEFAULT_TOTAL);
        return queryCompanyResponseDTO;
    }

    /***
     * 组装返回参数
     * @param result
     * @return
     */
    private QueryCompanyCommerceInformationResponseDTO buildCompanyInfoResponse(CompanyCompanyBackgroundCommerceImformationEntity result) {
        QueryCompanyCommerceInformationResponseDTO responseDTO = new QueryCompanyCommerceInformationResponseDTO();
        responseDTO.setCompanyName(result.getCompany_companybackground_CommerceImformation_name());
        responseDTO.setApprovalDate(result.getCompany_companybackground_CommerceImformation_approvalDate());
        responseDTO.setBusinessAddress(result.getCompany_listedCompany_detailInfor_businessAddress());
        responseDTO.setBusinessRegistration(result.getCompany_listedCompany_detailInfor_businessRegistration());
        responseDTO.setBusinessScope(result.getCompany_listedCompany_mainBusinessIntro_businessScope());
        responseDTO.setBusinessTerm(result.getCompany_companybackground_CommerceImformation_businessTerm());
        responseDTO.setEnglishName(result.getCompany_listedCompany_detailInfor_englishName());
        responseDTO.setEstablishmentDate(result.getCompany_listedCompany_issueRelated_establishmentDate());
        responseDTO.setIndustry(result.getCompany_listedCompany_detailInfor_industry());
        responseDTO.setInsuredNumber(result.getCompany_companybackground_CommerceImformation_approvalDate());
        responseDTO.setApprovalDate(result.getCompany_companybackground_CommerceImformation_approvalDate());
        responseDTO.setLegalRepresentative(result.getCompany_listedCompany_detailInfor_legalRepresentative());
        responseDTO.setListingDate(result.getCompany_companybackground_CommerceImformation_listingDate());
        responseDTO.setListingPlate(result.getCompany_companybackground_CommerceImformation_listingPlate());
        responseDTO.setListingStatus(result.getCompany_companybackground_CommerceImformation_listingStatus());
        responseDTO.setMail(result.getCompany_listedCompany_detailInfor_mailbox());
        responseDTO.setManagementState(result.getCompany_companybackground_CommerceImformation_managementState());
        responseDTO.setNameUsed(result.getCompany_companybackground_CommerceImformation_nameUsed());
        responseDTO.setOrgCode(result.getCompany_companybackground_CommerceImformation_orgCode());
        responseDTO.setPaidInCapital(result.getCompany_companybackground_CommerceImformation_paidInCapital());
        responseDTO.setRegAuthority(result.getCompany_companybackground_CommerceImformation_regAuthority());
        responseDTO.setRegisteredAddress(result.getCompany_listedCompany_detailInfor_registeredAddress());
        responseDTO.setRegisteredCapital(result.getCompany_listedCompany_detailInfor_registeredCapital());
        responseDTO.setRegisterNo(result.getCompany_companybackground_CommerceImformation_RegisterNo());
        responseDTO.setStaffNumbers(result.getCompany_listedCompany_detailInfor_staffNumbers());
        responseDTO.setTaxpayerNo(result.getCompany_companybackground_CommerceImformation_taxpayerNo());
        responseDTO.setTaxpayerQua(result.getCompany_companybackground_CommerceImformation_taxpayerQua());
        responseDTO.setTelphone(result.getCompany_listedCompany_detailInfor_tel());
        responseDTO.setType(result.getCompany_companybackground_CommerceImformation_Type());
        responseDTO.setWebsiteAddress(result.getCompany_listedCompany_detailInfor_websiteAddress());
        return responseDTO;
    }
}
